CrudWindowsCount = 0;

			function NewCrudWindow(ServiceURL,ServiceParams,ModelName)
			{
				var WinDivID = CreateDomForCrudWindow();
				var svcUrl = ServiceURL;
				var svcParams = ServiceParams;
				
				NewCrudGrid(svcUrl,svcParams,WinDivID,ModelName);
				TurnCrudDivIntoDialog(WinDivID);
			}
			
			
			
			
			function CreateDomForCrudWindow()
			{
				var WindowsID = "CrudWindow-"+CrudWindowsCount;
				$('body').append("<div id='"+WindowsID+"' title='CRUD Window'></div>"); //un nuevo div para una nueva ventana
								
				CrudWindowsCount++;
				
				return WindowsID;
			}
			
			function TurnCrudDivIntoDialog(WinDivID)
			{
				
				$("#"+WinDivID).dialog(
					{
						height:'auto',
						width:'auto',
						buttons: 
						{
							Ok: function() 
							{
								$( this ).dialog( "close" );
								$(this).remove();
							}
						},
						close: function(event, ui)
						{
							$(this).dialog( "close" ); //Close the Dialog
							$(this).remove();	//Remove all the appended Dom and its assocciated events
						}
				});	
				
				
			}
			
			
	  
		
		
	 	
		


		
				